<template>
  <div class="info" v-loading="loading">
    <div class="card_con search_data mb15">
      <el-row class="mb15">
        <el-col :span="5" class="pr40">
          <div class="fz13 mb10">任务名：</div>
          <el-input v-model="keyName" placeholder="请输入任务名"></el-input>
        </el-col>
        <el-col :span="8" class="pr40">
          <div class="fz13 mb10">时间</div>
          <el-date-picker
            value-format="yyyy-MM-dd HH:mm:ss"
            v-model="time"
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </el-col>
        <el-col :span="5" class="pr40">
          <div class="fz13 mb10">状态：</div>
          <el-select v-model="scoreStatusId" placeholder="请选择">
            <el-option
              v-for="item in scoreStatusArr"
              :key="item.id"
              :label="item.name"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="3">
          <div class="fz13 mb10">&nbsp;</div>
          <el-button type="primary" @click="handleSearch">查询</el-button>
        </el-col>
      </el-row>
    </div>
    <div class="card_con">
      <div class="row mb15">
        <span class="l" @click="handleAdd">
          <i class="el-icon-circle-plus-outline"></i>添加商品
        </span>
      </div>
      <el-table
        border
        :data="tableData"
        :header-cell-style="{
          'text-align': 'center',
        }"
        :cell-style="{ 'text-align': 'center' }"
        style="width: 100%"
        highlight-current-row
      >
        <el-table-column type="selection" min-width="5%"> </el-table-column>
        <el-table-column prop="id" label="id" min-width="10%">
        </el-table-column>
        <el-table-column prop="name" label="任务名" min-width="20%">
        </el-table-column>
        <el-table-column prop="cate_text" label="发放积分" min-width="10%">
        </el-table-column>
        <el-table-column prop="price" label="人数" min-width="10%">
        </el-table-column>
        <el-table-column prop="is_online" label="发放时间" min-width="10%">
        </el-table-column>
        <el-table-column prop="is_online" label="备注" min-width="10%">
        </el-table-column>
        <el-table-column label="操作" min-width="30%">
          <template slot-scope="scope">
            <div class="caozuo">
              <div
                class="handleExamine hand_cs"
                @click="handleDetail(scope.row)"
              >
                详情
              </div>
              <div class="handleEdit hand_cs" @click="handleEdit(scope.row)">
                编辑
              </div>
              <div
                class="handleDelete red hand_cs"
                @click="handleDelete(scope.row)"
              >
                删除
              </div>
            </div>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <Pagination :page="page" @onCurrentChange="handleCurrentChange" />
      </div>
      <!-- 编辑 添加 -->
      <el-dialog
        class="editDialog"
        :title="title"
        :visible.sync="dialogVisible"
        width="800px"
        :close-on-click-modal="false"
      >
        <Dialog
          v-if="dialogVisible"
          :rowData="rowData"
          @handleClose="handleClose"
        ></Dialog>
      </el-dialog>
    </div>
  </div>
</template>

<script>
import Pagination from "@/components/Pagination.vue";
export default {
  components: { Pagination },
  data() {
    return {
      loading: false,
      keyName: "",
      time: "",
      tableData: [{ is_online: "1212" }],
      page: {
        total: 0,
        pageNum: 1, // 当前页数
        pageSize: 10, // 每页的条数
      },
      dialogVisible: false,
      scoreStatusId: "",
      scoreStatusArr: [
        { id: "", name: "全部" },
        { id: "0", name: "待审核" },
        { id: "1", name: "待执行" },
        { id: "2", name: "已执行" },
        { id: "3", name: "已取消" },
      ],
      rowData: {}, //当前行的数据
      title: "",
    };
  },
  methods: {
    //查询
    handleSearch() {
      this.loading = true;
      this.page.pageNum = 1;
      this.allShopList();
    },
    //新增
    handleAdd() {
      this.rowData = {};
      this.dialogVisible = true;
      this.title = "新增";
    },
    //编辑
    handleEdit(row) {
      this.rowData = row;
      this.dialogVisible = true;
      this.title = "编辑";
    },
    //详情
    handleDetail(row) {
      this.rowId = row;
      this.detailDialog = true;
    },
    //级联
    cascaderChange() {
      this.typeId;
    },
    //删除
    handleDelete(row) {
      this.$confirm("是否确认删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          this.remarks_state = "3";
          this.rowId = row.id;
          this.switchRemark();
          //   this.$message({
          //     type: "success",
          //     message: "删除成功!",
          //     showClose: true,
          //   });
        })
        .catch(() => {
          ("1111111111111");
        });
    },
    //批量删除
    handleAllDelete() {
      if (this.selectionKeys.length === 0) {
        this.$message({
          showClose: true,
          message: "请选择要操作的数据",
          type: "warning",
        });
      } else {
        this.$confirm("是否确认删除?", "提示", {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        })
          .then(() => {
            this.remarks_state = "3";
            this.switchRemark();
            //   this.$message({
            //     type: "success",
            //     message: "删除成功!",
            //     showClose: true,
            //   });
          })
          .catch(() => {});

        //掉接口
      }
    },
    // 当前页: ${val}
    handleCurrentChange(val) {
      this.page.pageNum = val;
      this.loading = true;
      this.allShopList();
    },
    //关闭添加编辑
    handleClose() {
      this.dialogVisible = false;
      this.allShopList();
    },
    //开关编辑
    changeSwitch(row) {
      //0上架 1   1下架 2
      this.up_down_dialog = true;
      this.rowId = row.id;
      row.status;
      this.remarks_state = row.status;
      //   if (row.status === 1) {
      //     //1上架 操作下架
      //     this.remarks_state = 2;
      //   } else {
      //     //2下架  操作上架
      //     this.remarks_state = 1;
      //   }
      //
    },
    //开关备注提交
    handleRemark() {
      this.up_down_dialog = false;
      this.switchRemark();
    },
    //开关弹窗关闭
    remarkClose() {
      this.up_down_dialog = false;
      this.remarks = "";
      this.allShopList();
    },
  },
  created() {
    this.shopCategory();
  },
};
</script>

<style lang="scss" scoped>
@import "@/style/index.scss";

.info {
  .title {
    font-size: 16px;
    margin-bottom: 13px;
  }
}
.pagination {
  display: flex;
  justify-content: flex-end;
  padding-top: 10px;
}
.el-select {
  width: 100%;
}

.tb {
  background-color: #fff;
  padding: 20px;
  box-sizing: border-box;
}
.row {
  display: flex;
  border-radius: 2px;
  //   border: 1px solid #ccc;
  .l {
    padding: 8px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ccc;
    font-size: 13px;
    i {
      margin-right: 6px;
      font-size: 13px;
    }
    &:hover {
      cursor: pointer;
    }
  }
}
.editDialog {
  //   z-index: 2005 !important;
  /deep/.el-dialog {
    height: 75%;
    .el-dialog__body {
      height: 89%;
      overflow: auto;
    }
  }
}
.handleEdit {
  margin-left: 20px;
}
.handleDelete {
  margin-left: 20px;
}

/deep/.el-table .el-table__cell {
  padding: 10px 0;
}
.search_data {
  /deep/.el-input__inner {
    height: 36px;
    line-height: 36px;
    font-size: 13px;
  }
}

.beizhu {
  padding-left: 20px;
  padding-bottom: 50px;
  box-sizing: border-box;
  .bz {
    margin-bottom: 10px;
  }
}
</style>
<style>
.v-modal {
  z-index: 2000 !important;
}
</style>
